package com.heima.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.service.ApUserRealnameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author chenshan
 */
@RestController
@RequestMapping("api/v1/auth")
public class UserRealNameController {
    @Autowired
    private ApUserRealnameService userRealnameService;

    /**
     * 查询用户审核列表
     * @param authDto 查询条件
     * @return ResponseResult
     */
    @PostMapping("list")
    public ResponseResult listUserRealname(@RequestBody AuthDto authDto) {
        return userRealnameService.listUserRealname(authDto);
    }

    /**
     * 用户审核通过
     * @param map 审核信息
     * @return ResponseResult
     */
    @PostMapping("authPass")
    public ResponseResult authPass(@RequestBody Map<String, Object> map) {
        Integer id = (Integer) map.get("id");
        String msg = (String) map.get("msg");
        return userRealnameService.authPass(id, msg);
    }

    /**
     * 用户审核驳回
     * @param map 审核信息
     * @return ResponseResult
     */
    @PostMapping("authFail")
    public ResponseResult authFail(@RequestBody Map<String, Object> map) {
        Integer id = (Integer) map.get("id");
        String msg = (String) map.get("msg");
        return userRealnameService.authFail(id, msg);
    }

}
